<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"
        content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="author" content="火星科技 http://cesium.marsgis.cn ">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="x5-fullscreen" content="true">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta name="description"
        content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS" />

    <link rel="shortcut icon" type="image/x-icon" href="http://cesium.marsgis.cn/favicon.ico">
    <title>三维地图 |Mars3D ( MarsGIS for Cesium )|三维地图| 火星科技|合肥火星科技|合肥火星科技有限公司</title>


    <!--第三方lib-->
    <script type="text/javascript" src="../lib/include-lib.js" libpath="../lib/"
        include="jquery,font-awesome,bootstrap,layer,haoutil,turf,mars3d"></script>

    <link href="css/style.css" rel="stylesheet" />
</head>

<body class="dark">
    <!--加载前进行操作提示，优化用户体验-->
    <div id="mask" class="signmask" onclick="removeMask()"></div>

    <div id="cesiumContainer" class="mars3d-container"></div>


    <!-- 面板 -->
    <div class="infoview">
        <input type="button" class="btn btn-primary" value="开始漫游" onclick="startFly()" />
        <input type="button" class="btn btn-primary" value="停止漫游" onclick="stopFly()" />

        其他室内视角：
        <input type="button" class="btn btn-primary" value="教室" onclick="centerAtDX1()" />
        <input type="button" class="btn btn-primary" value="走廊" onclick="centerAtDX2()" />
        <input type="button" class="btn btn-primary" value="楼梯间" onclick="centerAtDX3()" />

    </div>


    <script type="text/javascript">
        $(document).ready(function () {
            if (!mars3d.util.webglreport()) {
                alert('系统检测到您使用的浏览器不支持WebGL功能');
                layer.open({
                    type: 1,
                    title: "当前浏览器不支持WebGL功能",
                    closeBtn: 0,
                    shadeClose: false,
                    resize: false,
                    area: ['600px', '200px'], //宽高
                    content: '<div style="margin: 20px;"><h3>系统检测到您使用的浏览器不支持WebGL功能！</h3>  <p>1、请您检查浏览器版本，安装使用最新版chrome、火狐或IE11以上浏览器！</p> <p>2、WebGL支持取决于GPU支持，请保证客户端电脑已安装显卡驱动程序！</p></div>'
                });
            }

            initMap();
        });

        function removeMask() {
            $("#mask").remove();
        }


        var viewer;
        //初始化地图
        function initMap() {
            //url传参，一个系统动态使用不同配置
            var configfile = haoutil.system.getRequestByName("config", "config/config.json");

            mars3d.createMap({
                id: 'cesiumContainer',
                url: configfile,
                center: { "y": 31.842655, "x": 117.251587, "z": 304.57, "heading": 358, "pitch": -59, "roll": 360 },
                animation: true,       //是否创建动画小器件，左下角仪表
                timeline: true,        //是否显示时间线控件
                operationallayers: [
                    {
                        "id": 1987,
                        "name": "教学楼",
                        "type": "3dtiles",
                        "url": serverURL_3dtiles + "/bim-daxue/tileset.json", //定义在 config\marsUrl.js 
                        "offset": { "x": 117.251229, "y": 31.844015, "z": 36.2, "transform": true },
                        "center": { "y": 31.842655, "x": 117.251587, "z": 304.57, "heading": 358, "pitch": -59, "roll": 360 },
                        "maximumScreenSpaceError": 16,
                        "maximumMemoryUsage": 1024,
                        "showClickFeature": true,
                        "popup": "all",
                        "scenetree": "scenetree.json",
                        "showClickFeature": true,
                        "pickFeatureStyle": {
                            "color": "#00FF00"
                        },
                        "popup": "all",
                        "visible": true
                    }
                ],
                success: function (_viewer, jsondata) {//地图成功加载完成后执行
                    viewer = _viewer;

                    setTimeout(removeMask, 3000);
                    initWork();
                }
            });
        }

        var flyLine

        //当前页面业务相关
        function initWork() {

            //键盘漫游
            viewer.mars.keyboardRoam.bind({
                moveStep: 0.1,    //平移步长 (米)。
                dirStep: 50,        //相机原地旋转步长，值越大步长越小。
                rotateStep: 0.3,    //相机围绕目标点旋转速率，0.3-2.0
                minPitch: 0.1,      //最小仰角  0-1
                maxPitch: 0.95,     //最大仰角  0-1
            });



            //该数据可以从 基础项目 飞行漫游功能界面操作后单个路线的 保存JSON
            var flydata = {
                "name": "室内路线",
                "camera": { "type": "dy", "followedX": 1, "followedZ": 0.2 },
                "points": [[117.25164, 31.843773, 36.68], [117.251042, 31.843772, 36.68], [117.250613, 31.844058, 36.68], [117.250677, 31.844146, 38.68], [117.250696, 31.844134, 38.68], [117.250657, 31.844098, 40.68], [117.250611, 31.84406, 40.68], [117.251039, 31.843773, 40.68]],
                "speed": 5,
                "offsetHeight": 1.6
            };
            flyLine = new mars3d.FlyLine(viewer, flydata);
            flyLine.start();



        }


        function startFly() {
            flyLine.start();

        }

        function stopFly() {
            flyLine.stop();
            haoutil.msg("您可以键盘按A S D W Q E键控制前后左右, 上下左右键控制旋转, 进行手动漫游。")

        }


        function centerAtDX1() {
            stopFly()
            viewer.mars.centerAt({ "y": 31.84371, "x": 117.251041, "z": 38.51, "heading": 56.1, "pitch": -8.1, "roll": 0.1 });
        }

        function centerAtDX2() {
            stopFly()
            viewer.mars.centerAt({ "y": 31.84381, "x": 117.250991, "z": 38.41, "heading": 305.9, "pitch": -12.3, "roll": 359.9 });
        }

        function centerAtDX3() {
            stopFly()
            viewer.mars.centerAt({ "y": 31.843787, "x": 117.251172, "z": 41.78, "heading": 17.2, "pitch": -9.3, "roll": 0.1 });
        }


    </script>
</body>

</html>